#!/bin/csh 
#.......................................................................
#
# Merge files with dates : 20071231 20080101 ... 20081231 20090101 
#
# Remapping to 2x2.5 grid 
#
# Author : Kai Zhang (kai.zhang@pnnl.gov)  
#
# Last modified date : 2014-06-04 
#
#.......................................................................

foreach yy (2003 2004 2005 2006 2007 2008 2009 2010 2011 )

set ya = `expr $yy - 1` ; echo $ya
set yb = `expr $yy + 1` ; echo $yb

foreach tp (BC OC SO2) 

foreach mm (01 02 03 04 05 06 07 08 09 10 11 12)
   rm -f daily_${tp}_${yy}${mm}.nc 
   cdo mergetime ${yy}/daily_${tp}_${yy}${mm}??.nc daily_${tp}_${yy}${mm}.nc >& null & 
end

   wait 

   rm -f GFED3.1_daily_${tp}_${yy}.nc 
   rm -f GFED3.1_daily_${tp}_${yy}_2x2.5.nc  
 
   cdo mergetime daily_${tp}_${ya}1231.nc daily_${tp}_${yy}??.nc daily_${tp}_${yb}0101.nc GFED3.1_daily_${tp}_${yy}.nc 

   cdo remapcon,cam5_grid_144x96  GFED3.1_daily_${tp}_${yy}.nc  GFED3.1_daily_${tp}_${yy}_2x2.5.nc >& null & 

end

end



